/*
 * $Id: SkvList.h,v 1.5 2006-04-24 08:42:10 bacon Exp $
 */

#ifndef _XPP_UTL_SKVLIST_CLASS_
#define _XPP_UTL_SKVLIST_CLASS_

#include <xpp/Named.h>
#include <xpp/bas/String.h>
#include <xpp/bas/LinkedList.h>
#include <xpp/bas/Pair.h>

namespace xpp
{
	namespace utl 
	{

		typedef xpp::bas::Pair<xpp::bas::String,xpp::bas::String> SkvPair;
		typedef xpp::bas::LinkedList<SkvPair> SkvPairList;
		
		class SkvSctn: public Named, public SkvPairList 
		{
		public:
			SkvSctn () {}
			SkvSctn (const xp_char_t* n): Named (n) {}
		
			SkvPair* addPair (const xp_char_t* key);
			int removePair (const xp_char_t* key);
			SkvPair* findPair (const xp_char_t* key) const;
			bool pairExists (const xp_char_t* key) const;
			const xp_char_t* valueOf (const xp_char_t* key) const;
			SkvPair* setValue (const xp_char_t* key, const xp_char_t* val);	
		};
		
		class SkvList: public xpp::bas::LinkedList<SkvSctn> 
		{
		public:
			SkvList (xp_size_t mpb_size = 0): 
				xpp::bas::LinkedList<SkvSctn> (mpb_size) {}

			SkvSctn* addSection (const xp_char_t* sctn);
			SkvPair* addPair (const xp_char_t* sctn, const xp_char_t* key);

			int removeSection (const xp_char_t* sctn);
			int removePair (const xp_char_t* sctn, const xp_char_t* key);

			SkvSctn* findSection (const xp_char_t* sctn) const;
			SkvPair* findPair (
				const xp_char_t* sctn, const xp_char_t* key) const;

			bool sectionExists (const xp_char_t* sctn) const;
			bool pairExists (const
				 xp_char_t* sctn, const xp_char_t* key) const;
			const xp_char_t* valueOf (
				const xp_char_t* sctn, const xp_char_t* key) const;

			SkvSctn* setValue (const xp_char_t* sctn,
				const xp_char_t* key, const xp_char_t* val);	
		};

	}		
}

#endif
		
